/*****************************************************************************\

File:   otkExamplesMain.java


Date          Build     Author        Version   Comments
08-Aug-12    P-20-11    aphatak       $$1       Created
03-Sep-12    P-20-13    asonar        $$2       Updated
18-Sep-12    P-20-14    asonar        $$3       Updated
19-Sep-12    P-20-14    dshah         $$4       Updated
12-Oct-12    P-20-14    dshah         $$5       Updated
30-Oct-12    P-20-16    dshah         $$6       Updated
01-Nov-12    P-20-16    dshah         $$7       Updated
14-Dec-12    P-20-19    asonar        $$8       Updated
29-May-14    P-20-54    rkothari      $$9      Added addUIFCExample
20-mar-15 P-30-05 gshmelev $$10  called GetCurrentSession
31-Mar-15  P-30-05 gshmelev  $$11 called GetCurrentSessionWithCompatibility
\****************************************************************************/
package com.ptc.otkjavaexamples;


import com.ptc.cipjava.*;
import com.ptc.otkjavaexamples.util.DebugRedirector;
import com.ptc.pfc.pfcGlobal.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcCommand.*;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcSolid.*;
import com.ptc.wfc.wfcSession.*;
import com.ptc.wfc.wfcDisplay.*;

import java.util.*;
import java.io.*;
import com.ptc.otkjavaexamples.ui.*;

/* The OTK Java Examples Main Class */
public class otkExamplesMain {
	static {
		DebugRedirector.redirector();
	}



   public static void start ()
    {
	   new otkExamplesMain ();
    }
  
   public static void stop ()
    {
    }


   public otkExamplesMain ()
   {
		SetupRibbonCommands();
   }

   private Session session;
   private WSession wSession;

   private static final String ribbonFile = "otkJavaExamples.rbn";
   private static final String msgFile = "otkjavamessage.txt";
   /* Load the OTK Java Examples Ribbon & add Example commands */
   private void SetupRibbonCommands()
   {
		try
		{
			session = pfcSession.GetCurrentSessionWithCompatibility (CreoCompatibility.C4Compatible);
			wSession = (WSession)session;

			wSession.RibbonDefinitionfileLoad(ribbonFile);
			
			addFamilyMemberExampleCommand();
			addCreateSection2DCommand();
			addCreateSection3DCommand();
			addRasterExportCommand();
			addWTServerExampleCommand();
			addDrawingCommand();
			addQuickPrintCommand();
			addUDFCommand();
			addFeatOperationsCommand();
			addCreateNewCombStateCommand();
			addCombinedStateInfoCommand();
			addDeleteCombinedStateCommand();
			addCreateLayerStateCommand();
			addLayerStateInfoCommand();
			addUpdateLayerStateCommand();
			addDeleteLayerStateCommand();
			addListFeaturesCommand();
			addSessionUtilsCommand();
			addFamilyTableEditExampleCommand();
			addFamilyTableEraseExampleCommand();
			addFamilyTableInfoExampleCommand();
			addFamilyTableRowSelectExampleCommand();
			addFamilyTableShowExampleCommand();
			addModelUtilsCommand();
			addXSectionExampleCommand();
			addAssemblyItemOperationsExampleCommand();
			addGeometryExampleCommand();
			addLightingExampleCommand();
			addCreateSweepCommand();
			addUIFCExample();
			addDialog1();
			addTechniqueViewController();

		}
		catch (Throwable e)
	    {
		  System.out.println ("Exception caught: "+e);
		  e.printStackTrace ();
	    }
    }

    /* Designate the family table example Command */
	private void addFamilyMemberExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_1", new otkFamilyMemberExample() );
	  cmd.Designate(msgFile, "Family Member Example", "Family Member Example", "Family Member Example");

	}

	/* Designate the windchill server example Command */
	private void addWTServerExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_2", new otkWTServerExample() );
	  cmd.Designate(msgFile, "Do Server Operations", "Do Server Operations", "Do Server Operations");

	}

	/* Designate the Section2D example Command */
	private void addCreateSection2DCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_3", new otkCreateSection2D() );
	  cmd.Designate(msgFile, "Create a 2D Section", "Create a 2D Section", "Create a 2D Section");

	}
		
	/* Designate the Section3D example Command */
	private void addCreateSection3DCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_4", new otkCreateSection3D() );
	  cmd.Designate(msgFile, "3D Section operations", "3D Section operations", "3D Section operations");

	}
	
	/* Designate the Drawing example Command */
	private void addDrawingCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_5", new otkDrawing() );
	  cmd.Designate(msgFile, "Create Drawing Sheets and Views", "Create Drawing Sheets and Views", "Create Drawing Sheets and Views");

	}
	
	/* Designate the QuickPrint example Command */
	private void addQuickPrintCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_6", new otkQuickPrint() );
	  cmd.Designate(msgFile, "Quick Print", "Quick Print", "Quick Print");

	}

	/* Designate the RasterExport example Command */
	private void addRasterExportCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_7", new otkRasterExport() );
	  cmd.Designate(msgFile, "Export To Raster file type", "Export To Raster file type", "Export To Raster file type");

	}

	/* Designate the otkUDF example Command */
	private void addUDFCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_8", new otkUDF() );
	  cmd.Designate(msgFile, "Create Node UDF in Part", "Create Node UDF in Part", "Create Node UDF in Part");

	}
	
	/* Performs different operations on feature. */
	private void addFeatOperationsCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_9", new otkFeatOperationsExample() );
	  cmd.Designate(msgFile, "Do Feature Operations", "Do Feature Operations", "Do Feature Operations");

	}

	/*Create a New Combined State.*/
	private void addCreateNewCombStateCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_10", new otkCreateNewCombStateExample() );
	  cmd.Designate(msgFile, "Create new combined state", "Create new combined state", "Create new combined state");

	}

	/*Shows combined state info into Pro/E browser window.*/
	private void addCombinedStateInfoCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_11", new otkCombinedStateInfoExample() );
	  cmd.Designate(msgFile, "Combined state info", "Combined state info", "Combined state info");

	}

	/*Delete Combined State.*/
	private void addDeleteCombinedStateCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_12", new otkDeleteCombinedStateExample() );
	  cmd.Designate(msgFile, "Delete combined state", "Delete combined state", "Delete combined state");

	}

	/*Create New Layer State.*/
	private void addCreateLayerStateCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_13", new otkCreateLayerStateExample() );
	  cmd.Designate(msgFile, "Create new layer state", "Create new layer state", "Create new layer state");

	}

	/*Shows layer state info into Pro/E browser window.*/
	private void addLayerStateInfoCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_14", new otkLayerStateInfoExample() );
	  cmd.Designate(msgFile, "Layer state info", "Layer state info", "Layer state info");

	}

	/*Update existing Layer State*/
	private void addUpdateLayerStateCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_15", new otkUpdateLayerStateExample() );
	  cmd.Designate(msgFile, "Update layer state", "Update layer state", "Update layer state");

	}

	/*Delete a layer state*/
	private void addDeleteLayerStateCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_16", new otkDeleteLayerStateExample() );
	  cmd.Designate(msgFile, "Delete layer state", "Delete layer state", "Delete layer state");

	}

	/*List Features info.*/
	private void addListFeaturesCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_17", new otkListFeaturesExample() );
	  cmd.Designate(msgFile, "List Features Info", "List Features Info", "List Features Info");

	}

	/*Writes Current Session Information*/
	private void addSessionUtilsCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_18", new otkSessionUtils() );
	  cmd.Designate(msgFile, "Dump Session Info", "Dump Session Info", "Dump Session Info");

	}
	
	// Family Table Edit
	private void addFamilyTableEditExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_19", new otkFamilyTableEditExample() );
	  cmd.Designate(msgFile, "Family Table Edit", "Family Table Edit", "Family Table Edit");

	}
	
	// Family Table Erase
	private void addFamilyTableEraseExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_20", new otkFamilyTableEraseExample() );
	  cmd.Designate(msgFile, "Family Table Erase", "Family Table Erase", "Family Table Erase");

	}
	
	// Family Table Info
	private void addFamilyTableInfoExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_21", new otkFamilyTableInfoExample() );
	  cmd.Designate(msgFile, "Family Table Info", "Family Table Info", "Family Table Info");

	}
	
	// Family Table Single Row select
	private void addFamilyTableRowSelectExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_22", new otkFamilyTableRowSelectExample() );
	  cmd.Designate(msgFile, "Family Table row selection", "Family Table row selection", "Family Table row selection");

	}
	
	// Family Table Show
	private void addFamilyTableShowExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_23", new otkFamilyTableShowExample() );
	  cmd.Designate(msgFile, "Family Table Show", "Family Table Show", "Family Table Show");

	}
	
	//Dump Model Info
	private void addModelUtilsCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_24", new otkModelUtils() );
	  cmd.Designate(msgFile, "Dump Model Info", "Dump Model Info", "Dump Model Info");

	}

	//Cross Section Examples
	private void addXSectionExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmdPlanar;
	  UICommand cmdPlanarquilt;
	  UICommand cmdHatching;
	  UICommand cmdPlanarExcl;

	  cmdPlanar = wSession.UICreateCommand("otkJavaExample_25", new otkXSectionExample("Planar") );
	  cmdPlanar.Designate(msgFile, "Create Planar Section", "Create Planar Section", "Create Planar Section");

	  cmdPlanarquilt = wSession.UICreateCommand("otkJavaExample_26", new otkXSectionExample("Planar with quilt") );
	  cmdPlanarquilt.Designate(msgFile, "Create Planar Section with quilt", "Create Planar Section with quilt", "Create Planar Section with quilt");

	  cmdHatching = wSession.UICreateCommand("otkJavaExample_27", new otkXSectionExample("Edit Hatching") );
	  cmdHatching.Designate(msgFile, "Section Hatching Multi Edit", "Section Hatching Multi Edit", "Section Hatching Multi Edit");

	  cmdPlanarExcl = wSession.UICreateCommand("otkJavaExample_28", new otkXSectionExample("Planar with excluded parts") );
	  cmdPlanarExcl.Designate(msgFile, "Create Planar Section with excluded parts", "Create Planar Section with excluded parts", "Create Planar Section with excluded parts");

	  wSession.AddActionListener(new XSectionExamplesPopupMenu());

	}

	//Assembly Item Operations
	private void addAssemblyItemOperationsExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_29", new otkAssemblyItemOperationsExample() );
	  cmd.Designate(msgFile, "Assembly Item Operations", "Assembly Item Operations", "Assembly Item Operations");

	}
	
	//Dump Interface Data
	private void addGeometryExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_30", new otkGeometryExample() );
	  cmd.Designate(msgFile, "Dump Interface Data", "Dump Interface Data", "Dump Interface Data");

	}

	//Graphics Examples
	private void addLightingExampleCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd1;
	  UICommand cmd2;
	  UICommand cmd3;
	  UICommand cmd4;
	  UICommand cmd5;

	  cmd1 = wSession.UICreateCommand("otkJavaExample_31", new otkLightingExample(LightType.LIGHT_SPOT, false, false) );
	  cmd1.Designate(msgFile, "Add Spot Light", "Add Spot Light", "Add Spot Light");

	  cmd2 = wSession.UICreateCommand("otkJavaExample_32", new otkLightingExample(LightType.LIGHT_POINT, false, false) );
	  cmd2.Designate(msgFile, "Add Point Light", "Add Point Light", "Add Point Light");

	  cmd3 = wSession.UICreateCommand("otkJavaExample_33", new otkLightingExample(LightType.LIGHT_DIRECTION, false, false) );
	  cmd3.Designate(msgFile, "Add Direction Light", "Add Direction Light", "Add Direction Light");

	  cmd4 = wSession.UICreateCommand("otkJavaExample_34", new otkLightingExample(null, true, false) );
	  cmd4.Designate(msgFile, "Remove Light", "Remove Light", "Remove Light");

	  cmd5 = wSession.UICreateCommand("otkJavaExample_35", new otkLightingExample(null, false, true) );
	  cmd5.Designate(msgFile, "Display Light Information", "Display Light Information", "Display Light Information");

	}
	
	//Creates Sweep Feature
	private void addCreateSweepCommand () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_36", new otkCreateSweep() );
	  cmd.Designate(msgFile, "Create Sweep Feature", "Create Sweep Feature", "Create Sweep Feature");

	}

	//uifc
	private void addUIFCExample () throws com.ptc.cipjava.jxthrowable
	{
	  UICommand cmd;

	  cmd = wSession.UICreateCommand("otkJavaExample_37", new OTKServerRegistryDialog());
	  cmd.Designate(msgFile, "UIFC Dialog Demo", "UIFC Dialog Demo", "UIFC Dialog Demo");

	}

	//Dialog1
	private void addDialog1 () throws com.ptc.cipjava.jxthrowable
	{
		UICommand cmd;

		cmd = wSession.UICreateCommand("otkJavaExample_38", new Dialog1(session,wSession));
		cmd.Designate(msgFile, "UIFC Dialog1", "UIFC Dialog1", "UIFC Dialog1");

	}

	//addTechniqueViewController
	private void addTechniqueViewController () throws com.ptc.cipjava.jxthrowable
	{
		UICommand cmd;

		cmd = wSession.UICreateCommand("otkJavaExample_39", new TechniqueViewController(session));
		cmd.Designate(msgFile, "TechniqueViewController", "TechniqueViewController", "TechniqueViewController");

	}

}
